/**
* Copyright (c) 2012-2013 Nokia Corporation. All rights reserved.
* Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
* Oracle and Java are trademarks or registered trademarks of Oracle and/or its
* affiliates. Other product and company names mentioned herein may be trademarks
* or trade names of their respective owners. 
* See LICENSE.TXT for license information.
*/

package com.nokia.example.paint.views.components;

import com.nokia.example.paint.Main;
import javax.microedition.lcdui.Graphics;

/*
 * Tool for changing the color of the brush.
 */
public class ColorTool
    extends Button
    implements ColorChangeListener {

    protected int rectWidth = 46;
    protected int rectHeight = 41;
    protected int rectX = 0;
    protected int rectY = 0;
    private int currentColor = 0x000000;

    public ColorTool() {
        super("/color_highlight_small.png", "/color_small.png");
    }

    public void onSelected() {
        //show colorpicker
        Main.getInstance().getDrawArea().showColorPicker();
    }

    public void colorChanged(int newRGBColor) {
        currentColor = newRGBColor;
    }

    public void render(Graphics g) {
        g.setColor(currentColor);
        g.fillRect(x + rectX, y + rectY, rectWidth, rectHeight);
        super.render(g);
    }
}
